home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 15 / CU Amiga Magazine's Super CD-ROM 15 (1997)(EMAP Images)(GB)[!][issue 1997-10].iso / CUCD / Graphics / Ghostscript / source / gdevpsdf.c < prev    next >
C/C++ Source or Header  |  1997-05-17  |  19KB  |  614 lines

  1. /* Copyright (C) 1997 Aladdin Enterprises.  All rights reserved.
  2.   
  3.   This file is part of Aladdin Ghostscript.
  4.   
  5.   Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author
  6.   or distributor accepts any responsibility for the consequences of using it,
  7.   or for whether it serves any particular purpose or works at all, unless he
  8.   or she says so in writing.  Refer to the Aladdin Ghostscript Free Public
  9.   License (the "License") for full details.
  10.   
  11.   Every copy of Aladdin Ghostscript must include a copy of the License,
  12.   normally in a plain ASCII text file named PUBLIC.  The License grants you
  13.   the right to copy, modify and redistribute Aladdin Ghostscript, but only
  14.   under certain conditions described in the License.  Among other things, the
  15.   License requires that the copyright notice and this notice be preserved on
  16.   all copies.
  17. */
  18.  
  19. /* gdevpsdf.c */
  20. /* Common output syntax and parameters for PostScript and PDF writers */
  21. #include "stdio_.h"
  22. #include "string_.h"
  23. #include "gserror.h"
  24. #include "gserrors.h"
  25. #include "gsmemory.h"
  26. #include "gstypes.h"
  27. #include "gsparam.h"
  28. #include "gxdevice.h"
  29. #include "gdevpsdf.h"
  30. #include "gdevpstr.h"
  31. #include "strimpl.h"        /* for short-sighted compilers */
  32. #include "scfx.h"
  33. #include "slzwx.h"
  34. #include "srlx.h"
  35.  
  36. /* Structure descriptor */
  37. public_st_device_psdf();
  38.  
  39. /* ---------------- Get/put Distiller parameters ---------------- */
  40.  
  41. typedef struct psdf_image_filter_name_s {
  42.   const char *pname;
  43.   const stream_template *template;
  44. } psdf_image_filter_name;
  45. typedef struct psdf_image_param_names_s {
  46.   const char *ACSDict;        /* not used for mono */
  47.   const char *AntiAlias;
  48.   const char *AutoFilter;    /* not used for mono */
  49.   const char *Depth;
  50.   const char *Dict;
  51.   const char *Downsample;
  52.   const char *DownsampleType;
  53.   const char *Encode;
  54.   const char *Filter;
  55.   const char *Resolution;
  56. } psdf_image_param_names;
  57. private const psdf_image_param_names Color_names = {
  58.   "ColorACSImageDict", "AntiAliasColorImages", "AutoFilterColorImages",
  59.   "ColorImageDepth", "ColorImageDict",
  60.   "DownsampleColorImages", "ColorImageDownsampleType", "EncodeColorImages",
  61.   "ColorImageFilter", "ColorImageResolution"
  62. };
  63. private const psdf_image_filter_name Poly_filters[] = {
  64.   /*{"DCTEncode", &s_DCTE_template},*/
  65.   {"LZWEncode", &s_LZWE_template},
  66.   {0, 0}
  67. };
  68. private const psdf_image_param_names Gray_names = {
  69.   "GrayACSImageDict", "AntiAliasGrayImages", "AutoFilterGrayImages",
  70.   "GrayImageDepth", "GrayImageDict",
  71.   "DownsampleGrayImages", "GrayImageDownsampleType", "EncodeGrayImages",
  72.   "GrayImageFilter", "GrayImageResolution"
  73. };
  74. private const psdf_image_param_names Mono_names = {
  75.   0, "AntiAliasMonoImages", 0,
  76.   "MonoImageDepth", "MonoImageDict",
  77.   "DownsampleMonoImages", "MonoImageDownsampleType", "EncodeMonoImages",
  78.   "MonoImageFilter", "MonoImageResolution"
  79. };
  80. private const psdf_image_filter_name Mono_filters[] = {
  81.   {"CCITTFaxEncode", &s_CFE_template},
  82.   {"LZWEncode", &s_LZWE_template},
  83.   {"RunLengthEncode", &s_RLE_template},
  84.   {0, 0}
  85. };
  86. private const char *AutoRotatePages_names[] = {
  87.   "None", "All", "PageByPage", 0
  88. };
  89. private const char *ColorConversionStrategy_names[] = {
  90.   "LeaveColorUnchanged", "UseDeviceDependentColor",
  91.   "UseDeviceIndependentColor", 0
  92. };
  93. private const char *DownsampleType_names[] = {
  94.   "Average", "Subsample", 0
  95. };
  96. private const char *TransferFunctionInfo_names[] = {
  97.   "Preserve", "Apply", "Remove", 0
  98. };
  99. private const char *UCRandBGInfo_names[] = {
  100.   "Preserve", "Remove", 0
  101. };
  102.  
  103. /* -------- Get parameters -------- */
  104.  
  105. /* Get a set of image-related parameters. */
  106. private int
  107. psdf_get_image_params(gs_param_list *plist,
  108.   const psdf_image_param_names *pnames, psdf_image_params *params)
  109. {    int code;
  110.     gs_param_string dsts, fs;
  111.  
  112.     param_string_from_string(dsts,
  113.         DownsampleType_names[params->DownsampleType]);
  114.     if (
  115.          /* ACSDict */
  116.          (code = param_write_bool(plist, pnames->AntiAlias,
  117.                       ¶ms->AntiAlias)) < 0 ||
  118.          (pnames->AutoFilter != 0 &&
  119.           (code = param_write_bool(plist, pnames->AutoFilter,
  120.                        ¶ms->AutoFilter)) < 0) ||
  121.          (code = param_write_int(plist, pnames->Depth,
  122.                      ¶ms->Depth)) < 0 ||
  123.          /* Dict */
  124.          (code = param_write_bool(plist, pnames->Downsample,
  125.                       ¶ms->Downsample)) < 0 ||
  126.          (code = param_write_name(plist, pnames->DownsampleType,
  127.                       &dsts)) < 0 ||
  128.          (code = param_write_bool(plist, pnames->Encode,
  129.                       ¶ms->Encode)) < 0 ||
  130.          (code = (params->Filter == 0 ? 0 :
  131.               (param_string_from_string(fs, params->Filter),
  132.                param_write_name(plist, pnames->Filter, &fs)))) < 0 ||
  133.          (code = param_write_int(plist, pnames->Resolution,
  134.                      ¶ms->Resolution)) < 0
  135.        )
  136.       ;
  137.     return code;
  138. }
  139.  
  140. /* Get parameters. */
  141. int
  142. gdev_psdf_get_params(gx_device *dev, gs_param_list *plist)
  143. {    gx_device_psdf *pdev = (gx_device_psdf *)dev;
  144.     int code = gdev_vector_get_params(dev, plist);
  145.     gs_param_string arps, ccss, tfis, ucrbgis;
  146.  
  147.     if ( code < 0 )
  148.       return code;
  149.     param_string_from_string(arps,
  150.       AutoRotatePages_names[(int)pdev->params.AutoRotatePages]);
  151.     param_string_from_string(ccss,
  152.       ColorConversionStrategy_names[(int)pdev->params.ColorConversionStrategy]);
  153.     param_string_from_string(tfis,
  154.       TransferFunctionInfo_names[(int)pdev->params.TransferFunctionInfo]);
  155.     param_string_from_string(ucrbgis,
  156.       UCRandBGInfo_names[(int)pdev->params.UCRandBGInfo]);
  157.     if (
  158.             /* General parameters */
  159.  
  160.          (code = param_write_bool(plist, "ASCII85EncodePages",
  161.                       &pdev->params.ASCII85EncodePages)) < 0 ||
  162.          (code = param_write_name(plist, "AutoRotatePages",
  163.                       &arps)) < 0 ||
  164.          (code = param_write_bool(plist, "CompressPages",
  165.                       &pdev->params.CompressPages)) < 0 ||
  166.          (code = param_write_long(plist, "ImageMemory",
  167.                       &pdev->params.ImageMemory)) < 0 ||
  168.          (code = param_write_bool(plist, "LZWEncodePages",
  169.                       &pdev->params.LZWEncodePages)) < 0 ||
  170.          (code = param_write_bool(plist, "PreserveHalftoneInfo",
  171.                       &pdev->params.PreserveHalftoneInfo)) < 0 ||
  172.          (code = param_write_bool(plist, "PreserveOPIComments",
  173.                       &pdev->params.PreserveOPIComments)) < 0 ||
  174.          (code = param_write_bool(plist, "PreserveOverprintSettings",
  175.                       &pdev->params.PreserveOverprintSettings)) < 0 ||
  176.          (code = param_write_name(plist, "TransferFunctionInfo", &tfis)) < 0 ||
  177.          (code = param_write_name(plist, "UCRandBGInfo", &ucrbgis)) < 0 ||
  178.          (code = param_write_bool(plist, "UseFlateCompression",
  179.                       &pdev->params.UseFlateCompression)) < 0 ||
  180.  
  181.             /* Color sampled image parameters */
  182.  
  183.          (code = psdf_get_image_params(plist, &Color_names, &pdev->params.ColorImage)) < 0 ||
  184.          (code = param_write_name(plist, "ColorConversionStrategy",
  185.                       &ccss)) < 0 ||
  186.          (code = param_write_bool(plist, "ConvertCMYKImagesToRGB",
  187.                       &pdev->params.ConvertCMYKImagesToRGB)) < 0 ||
  188.          (code = param_write_bool(plist, "ConvertImagesToIndexed",
  189.                       &pdev->params.ConvertImagesToIndexed)) < 0 ||
  190.  
  191.             /* Gray sampled image parameters */
  192.  
  193.          (code = psdf_get_image_params(plist, &Gray_names, &pdev->params.GrayImage)) < 0 ||
  194.  
  195.             /* Mono sampled image parameters */
  196.  
  197.          (code = psdf_get_image_params(plist, &Mono_names, &pdev->params.MonoImage)) < 0 ||
  198.  
  199.             /* Font embedding parameters */
  200.  
  201.          (code = param_write_name_array(plist, "AlwaysEmbed", &pdev->params.AlwaysEmbed)) < 0 ||
  202.          (code = param_write_name_array(plist, "NeverEmbed", &pdev->params.NeverEmbed)) < 0 ||
  203.          (code = param_write_bool(plist, "EmbedAllFonts", &pdev->params.EmbedAllFonts)) < 0 ||
  204.          (code = param_write_bool(plist, "SubsetFonts", &pdev->params.SubsetFonts)) < 0 ||
  205.          (code = param_write_int(plist, "MaxSubsetPct", &pdev->params.MaxSubsetPct)) < 0
  206.        )
  207.       ;
  208.     return code;
  209. }
  210.  
  211. /* -------- Put parameters -------- */
  212.  
  213. /* Compare a C string and a gs_param_string. */
  214. bool
  215. psdf_key_eq(const gs_param_string *pcs, const char *str)
  216. {    return (strlen(str) == pcs->size &&
  217.         !strncmp(str, (const char *)pcs->data, pcs->size));
  218. }
  219.  
  220. /* Get an enumerated value. */
  221. private int
  222. psdf_put_enum_param(gs_param_list *plist, gs_param_name param_name, int *pvalue,
  223.   const char **pnames, int ecode)
  224. {    gs_param_string ens;
  225.     int code = param_read_name(plist, param_name, &ens);
  226.  
  227.     switch ( code )
  228.       {
  229.       case 1:
  230.         return ecode;
  231.       case 0:
  232.         { int i;
  233.           for ( i = 0; pnames[i] != 0; ++i )
  234.         if ( psdf_key_eq(&ens, pnames[i]) )
  235.           { *pvalue = i;
  236.             return 0;
  237.           }
  238.         }
  239.         code = gs_error_rangecheck;
  240.       default:
  241.         ecode = code;
  242.         param_signal_error(plist, param_name, code);
  243.       }
  244.     return code;
  245. }
  246.  
  247. /* Put a Boolean or integer parameter. */
  248. int
  249. psdf_put_bool_param(gs_param_list *plist, gs_param_name param_name,
  250.   bool *pval, int ecode)
  251. {    int code;
  252.  
  253.     switch ( code = param_read_bool(plist, param_name, pval) )
  254.     {
  255.     default:
  256.         ecode = code;
  257.         param_signal_error(plist, param_name, ecode);
  258.     case 0:
  259.     case 1:
  260.         break;
  261.     }
  262.     return ecode;
  263. }
  264. int
  265. psdf_put_int_param(gs_param_list *plist, gs_param_name param_name,
  266.   int *pval, int ecode)
  267. {    int code;
  268.  
  269.     switch ( code = param_read_int(plist, param_name, pval) )
  270.     {
  271.     default:
  272.         ecode = code;
  273.         param_signal_error(plist, param_name, ecode);
  274.     case 0:
  275.     case 1:
  276.         break;
  277.     }
  278.     return ecode;
  279. }
  280.  
  281. /* Put [~](Always|Never)Embed parameters. */
  282. private int
  283. psdf_put_embed_param(gs_param_list *plist, gs_param_name notpname,
  284.   gs_param_string_array *psa, int ecode)
  285. {    gs_param_name pname = notpname + 1;
  286.     int code;
  287.     gs_param_string_array nsa;
  288.  
  289.     /***** Storage management is incomplete ******/
  290.     /***** Doesn't do incremental add/delete ******/
  291.     switch ( code = param_read_name_array(plist, pname, psa) )
  292.       {
  293.       default:
  294.         ecode = code;
  295.         param_signal_error(plist, pname, ecode);
  296.       case 0:
  297.       case 1:
  298.         break;
  299.       }
  300.     switch ( code = param_read_name_array(plist, notpname, &nsa) )
  301.       {
  302.       default:
  303.         ecode = code;
  304.         param_signal_error(plist, notpname, ecode);
  305.       case 0:
  306.       case 1:
  307.         break;
  308.       }
  309.     return ecode;
  310. }
  311.  
  312. /* Put a set of image-related parameters. */
  313. private int
  314. psdf_put_image_params(gs_param_list *plist, const psdf_image_param_names *pnames,
  315.   const psdf_image_filter_name *pifn, psdf_image_params *params, int ecode)
  316. {    gs_param_string fs;
  317.     int dsti = params->DownsampleType;
  318.     int code;
  319.  
  320.     if ( pnames->ACSDict )
  321.       { /* ACSDict */
  322.       }
  323.     ecode = psdf_put_bool_param(plist, pnames->AntiAlias,
  324.                    ¶ms->AntiAlias, ecode);
  325.     if ( pnames->AutoFilter )
  326.       ecode = psdf_put_bool_param(plist, pnames->AutoFilter,
  327.                      ¶ms->AutoFilter, ecode);
  328.     ecode = psdf_put_int_param(plist, pnames->Depth,
  329.                   ¶ms->Depth, ecode);
  330.     /* Dict */
  331.     ecode = psdf_put_bool_param(plist, pnames->Downsample,
  332.                    ¶ms->Downsample, ecode);
  333.     if ( (ecode = psdf_put_enum_param(plist, pnames->DownsampleType,
  334.                      &dsti, DownsampleType_names,
  335.                      ecode)) >= 0
  336.        )
  337.       params->DownsampleType = (enum psdf_downsample_type)dsti;
  338.     ecode = psdf_put_bool_param(plist, pnames->Encode,
  339.                    ¶ms->Encode, ecode);
  340.     switch ( code = param_read_string(plist, pnames->Filter, &fs) )
  341.       {
  342.       case 0:
  343.         {    const psdf_image_filter_name *pn = pifn;
  344.         while ( pn->pname != 0 && !psdf_key_eq(&fs, pn->pname) )
  345.           pn++;
  346.         if ( pn->pname == 0 )
  347.           { ecode = gs_error_rangecheck;
  348.             goto ipe;
  349.           }
  350.         params->Filter = pn->pname;
  351.         params->filter_template = pn->template;
  352.         break;
  353.         }
  354.       default:
  355.         ecode = code;
  356. ipe:        param_signal_error(plist, pnames->Filter, ecode);
  357.       case 1:
  358.         break;
  359.       }
  360.     ecode = psdf_put_int_param(plist, pnames->Resolution,
  361.                   ¶ms->Resolution, ecode);
  362.     if ( ecode >= 0 )
  363.       { /* Force parameters to acceptable values. */
  364.         if ( params->Resolution < 1 )
  365.           params->Resolution = 1;
  366.         switch ( params->Depth )
  367.           {
  368.           default:
  369.         params->Depth = -1;
  370.           case 1: case 2: case 4: case 8:
  371.           case -1:
  372.         break;
  373.           }
  374.       }
  375.     return ecode;
  376. }
  377.  
  378. /* Put parameters. */
  379. int
  380. gdev_psdf_put_params(gx_device *dev, gs_param_list *plist)
  381. {    gx_device_psdf *pdev = (gx_device_psdf *)dev;
  382.     int ecode = 0;
  383.     int code;
  384.     gs_param_name param_name;
  385.     psdf_distiller_params params;
  386.  
  387.         /* General parameters. */
  388.  
  389.     params = pdev->params;
  390.  
  391.     ecode = psdf_put_bool_param(plist, "ASCII85EncodePages",
  392.                    ¶ms.ASCII85EncodePages, ecode);
  393.     { int arpi = params.AutoRotatePages;
  394.       ecode = psdf_put_enum_param(plist, "AutoRotatePages", &arpi,
  395.                       AutoRotatePages_names, ecode);
  396.       params.AutoRotatePages = (enum psdf_auto_rotate_pages)arpi;
  397.     }
  398.     ecode = psdf_put_bool_param(plist, "CompressPages",
  399.                    ¶ms.CompressPages, ecode);
  400.     switch ( code = param_read_long(plist, (param_name = "ImageMemory"), ¶ms.ImageMemory) )
  401.     {
  402.     default:
  403.         ecode = code;
  404.         param_signal_error(plist, param_name, ecode);
  405.     case 0:
  406.     case 1:
  407.         break;
  408.     }
  409.     ecode = psdf_put_bool_param(plist, "LZWEncodePages",
  410.                    ¶ms.LZWEncodePages, ecode);
  411.     ecode = psdf_put_bool_param(plist, "PreserveHalftoneInfo",
  412.                    ¶ms.PreserveHalftoneInfo, ecode);
  413.     ecode = psdf_put_bool_param(plist, "PreserveOPIComments",
  414.                    ¶ms.PreserveOPIComments, ecode);
  415.     ecode = psdf_put_bool_param(plist, "PreserveOverprintSettings",
  416.                    ¶ms.PreserveOverprintSettings, ecode);
  417.     { int tfii = params.TransferFunctionInfo;
  418.       ecode = psdf_put_enum_param(plist, "TransferFunctionInfo", &tfii,
  419.                      TransferFunctionInfo_names, ecode);
  420.       params.TransferFunctionInfo = (enum psdf_transfer_function_info)tfii;
  421.     }
  422.     { int ucrbgi = params.UCRandBGInfo;
  423.       ecode = psdf_put_enum_param(plist, "UCRandBGInfo", &ucrbgi,
  424.                      UCRandBGInfo_names, ecode);
  425.       params.UCRandBGInfo = (enum psdf_ucr_and_bg_info)ucrbgi;
  426.     }
  427.     ecode = psdf_put_bool_param(plist, "UseFlateCompression",
  428.                    ¶ms.UseFlateCompression, ecode);
  429.  
  430.         /* Color sampled image parameters */
  431.  
  432.     ecode = psdf_put_image_params(plist, &Color_names, Poly_filters,
  433.                      ¶ms.ColorImage, ecode);
  434.     { int ccsi = params.ColorConversionStrategy;
  435.       ecode = psdf_put_enum_param(plist, "ColorConversionStrategy", &ccsi,
  436.                      ColorConversionStrategy_names, ecode);
  437.       params.ColorConversionStrategy =
  438.         (enum psdf_color_conversion_strategy)ccsi;
  439.     }
  440.     ecode = psdf_put_bool_param(plist, "ConvertCMYKImagesToRGB",
  441.                    ¶ms.ConvertCMYKImagesToRGB, ecode);
  442.     ecode = psdf_put_bool_param(plist, "ConvertImagesToIndexed",
  443.                    ¶ms.ConvertImagesToIndexed, ecode);
  444.  
  445.         /* Gray sampled image parameters */
  446.  
  447.     ecode = psdf_put_image_params(plist, &Gray_names, Poly_filters,
  448.                      ¶ms.GrayImage, ecode);
  449.  
  450.         /* Mono sampled image parameters */
  451.  
  452.     ecode = psdf_put_image_params(plist, &Mono_names, Mono_filters,
  453.                      ¶ms.MonoImage, ecode);
  454.  
  455.             /* Font embedding parameters */
  456.  
  457.     ecode = psdf_put_embed_param(plist, "~AlwaysEmbed",
  458.                     ¶ms.AlwaysEmbed, ecode);
  459.     ecode = psdf_put_embed_param(plist, "~NeverEmbed",
  460.                     ¶ms.NeverEmbed, ecode);
  461.     ecode = psdf_put_bool_param(plist, "EmbedAllFonts",
  462.                    ¶ms.EmbedAllFonts, ecode);
  463.     ecode = psdf_put_bool_param(plist, "SubsetFonts",
  464.                    ¶ms.SubsetFonts, ecode);
  465.     ecode = psdf_put_int_param(plist, "MaxSubsetPct",
  466.                   ¶ms.MaxSubsetPct, ecode);
  467.  
  468.     if ( ecode < 0 )
  469.       return ecode;
  470.     code = gdev_vector_put_params(dev, plist);
  471.     if ( code < 0 )
  472.       return code;
  473.  
  474.     pdev->params = params;        /* OK to update now */
  475.     return 0;
  476. }
  477.  
  478. /* ---------------- Utilities ---------------- */
  479.  
  480. int
  481. psdf_set_color(gx_device_vector *vdev, const gx_drawing_color *pdc,
  482.   const char *rgs)
  483. {    if ( !gx_dc_is_pure(pdc) )
  484.       return_error(gs_error_rangecheck);
  485.     { stream *s = gdev_vector_stream(vdev);
  486.       gx_color_index color = gx_dc_pure_color(pdc);
  487.       float r = (color >> 16) / 255.0;
  488.       float g = ((color >> 8) & 0xff) / 255.0;
  489.       float b = (color & 0xff) / 255.0;
  490.  
  491.       if ( r == g && g == b )
  492.         pprintg1(s, "%g", r), pprints1(s, " %s\n", rgs + 1);
  493.       else
  494.         pprintg3(s, "%g %g %g", r, g, b), pprints1(s, " %s\n", rgs);
  495.     }
  496.     return 0;
  497. }
  498.  
  499. /* ---------------- Vector implementation procedures ---------------- */
  500.  
  501. int
  502. psdf_setlinewidth(gx_device_vector *vdev, floatp width)
  503. {    pprintg1(gdev_vector_stream(vdev), "%g w\n", width);
  504.     return 0;
  505. }
  506.  
  507. int
  508. psdf_setlinecap(gx_device_vector *vdev, gs_line_cap cap)
  509. {    pprintd1(gdev_vector_stream(vdev), "%d J\n", cap);
  510.     return 0;
  511. }
  512.  
  513. int
  514. psdf_setlinejoin(gx_device_vector *vdev, gs_line_join join)
  515. {    pprintd1(gdev_vector_stream(vdev), "%d j\n", join);
  516.     return 0;
  517. }
  518.  
  519. int
  520. psdf_setmiterlimit(gx_device_vector *vdev, floatp limit)
  521. {    pprintg1(gdev_vector_stream(vdev), "%g M\n", limit);
  522.     return 0;
  523. }
  524.  
  525. int
  526. psdf_setdash(gx_device_vector *vdev, const float *pattern, uint count,
  527.   floatp offset)
  528. {    stream *s = gdev_vector_stream(vdev);
  529.     int i;
  530.  
  531.     pputs(s, "[ ");
  532.     for ( i = 0; i < count; ++i )
  533.       pprintg1(s, "%g ", pattern[i]);
  534.     pprintg1(s, "] %g d\n", offset);
  535.     return 0;
  536. }
  537.  
  538. int
  539. psdf_setflat(gx_device_vector *vdev, floatp flatness)
  540. {    pprintg1(gdev_vector_stream(vdev), "%g i\n", flatness);
  541.     return 0;
  542. }
  543.  
  544. int
  545. psdf_setlogop(gx_device_vector *vdev, gs_logical_operation_t lop,
  546.   gs_logical_operation_t diff)
  547. {    /****** SHOULD AT LEAST DETECT SET-0 & SET-1 ******/
  548.     return 0;
  549. }
  550.  
  551. int
  552. psdf_setfillcolor(gx_device_vector *vdev, const gx_drawing_color *pdc)
  553. {    return psdf_set_color(vdev, pdc, "rg");
  554. }
  555.  
  556. int
  557. psdf_setstrokecolor(gx_device_vector *vdev, const gx_drawing_color *pdc)
  558. {    return psdf_set_color(vdev, pdc, "RG");
  559. }
  560.  
  561. int
  562. psdf_dorect(gx_device_vector *vdev, fixed x0, fixed y0, fixed x1, fixed y1,
  563.   gx_path_type_t type)
  564. {    int code = (*vdev_proc(vdev, beginpath))(vdev, type);
  565.     if ( code < 0 )
  566.       return code;
  567.     pprintg4(gdev_vector_stream(vdev), "%g %g %g %g re\n",
  568.          fixed2float(x0), fixed2float(y0),
  569.          fixed2float(x1 - x0), fixed2float(y1 - y0));
  570.     return (*vdev_proc(vdev, endpath))(vdev, type);
  571. }
  572.  
  573. int
  574. psdf_beginpath(gx_device_vector *vdev, gx_path_type_t type)
  575. {    return 0;
  576. }
  577.  
  578. int
  579. psdf_moveto(gx_device_vector *vdev, floatp x0, floatp y0, floatp x, floatp y,
  580.   bool first)
  581. {    pprintg2(gdev_vector_stream(vdev), "%g %g m\n", x, y);
  582.     return 0;
  583. }
  584.  
  585. int
  586. psdf_lineto(gx_device_vector *vdev, floatp xy, floatp y0, floatp x, floatp y)
  587. {    pprintg2(gdev_vector_stream(vdev), "%g %g l\n", x, y);
  588.     return 0;
  589. }
  590.  
  591. int
  592. psdf_curveto(gx_device_vector *vdev, floatp x0, floatp y0,
  593.   floatp x1, floatp y1, floatp x2, floatp y2, floatp x3, floatp y3)
  594. {    if ( x1 == x0 && y1 == y0 )
  595.       pprintg4(gdev_vector_stream(vdev), "%g %g %g %g v\n",
  596.            x2, y2, x3, y3);
  597.     else if ( x3 == x2 && y3 == y2 )
  598.       pprintg4(gdev_vector_stream(vdev), "%g %g %g %g y\n",
  599.            x1, y1, x2, y2);
  600.     else
  601.       pprintg6(gdev_vector_stream(vdev), "%g %g %g %g %g %g c\n",
  602.            x1, y1, x2, y2, x3, y3);
  603.     return 0;
  604. }
  605.  
  606. int
  607. psdf_closepath(gx_device_vector *vdev, floatp x0, floatp y0,
  608.   floatp x_start, floatp y_start)
  609. {    pputs(gdev_vector_stream(vdev), "h\n");
  610.     return 0;
  611. }
  612.  
  613. /* endpath is deliberately omitted. */
  614.